package com.shujia.flink.tf;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class Demo7Union {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<String> ds1 = env.socketTextStream("master", 8888);
        DataStreamSource<String> ds2 = env.socketTextStream("master", 9999);

        /*
         * union:合并两个DS
         * 在数据层面并没有合并，只是在逻辑层面合并了
         */
        DataStream<String> unionDS = ds1.union(ds2);

        unionDS.print();

        env.execute();
    }
}
